<style>
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
}
input[type='number'] {
  -moz-appearance: textfield;
}

</style>
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="" prop="schemeName">
        <el-input
          v-model="queryParams.schemeName"
          placeholder="请输入方案名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:scheme:add']"
        >新增方案
        </el-button>
      </el-col>
      <!--      <el-col :span="1.5">
              <el-button
                type="success"
                plain
                icon="el-icon-edit"
                size="mini"
                :disabled="single"
                @click="handleUpdate"
                v-hasPermi="['system:scheme:edit']"
              >修改</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                size="mini"
                :disabled="multiple"
                @click="handleDelete"
                v-hasPermi="['system:scheme:remove']"
              >删除</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="warning"
                plain
                icon="el-icon-download"
                size="mini"
                @click="handleExport"
                v-hasPermi="['system:scheme:export']"
              >导出</el-button>
            </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="schemeList" @selection-change="handleSelectionChange">
      <el-table-column label="序号" align="center" prop="sid"/>
      <el-table-column label="方案名称" align="center" prop="schemeName"/>
      <el-table-column label="参保城市" align="center" prop="schemeCity"/>
      <el-table-column label="使用人数" align="center" prop="cou"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:scheme:edit']"
          >编辑
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:scheme:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="90%" :close-on-click-modal='false' append-to-body
               border>

      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="方案名称" prop="schemeName">
              <el-input v-model="form.schemeName" placeholder="请输入方案名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="参保平台" prop="schemePlatform">
              <el-input v-model="form.schemePlatform" placeholder="请输入参保平台"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="参保城市" prop="schemeCity">
              <el-cascader
                size="large"
                :options="optionss"
                v-model="selectedAddressOptions"
                @change="handleChange">
              </el-cascader>
              <!--              <el-input  v-model="form.schemeCity" placeholder="请输入参保城市"/>-->
            </el-form-item>
          </el-col>
        </el-row>
        <h1>社保</h1>
        <el-divider></el-divider>

          <table border="1" cellspacing="1" cellpadding="0" bordercolor="#87cefa">
            <tr bgcolor="#87cefa">
              <td colspan="4" height="40" align="center">个人缴纳</td>
              <td colspan="4" height="40" align="center">企业缴纳</td>
            </tr>
            <tr bgcolor="#87cefa">
              <td width="11%" height="40" align="center">缴费项目</td>
              <td width="11%" height="40" align="center">基数</td>
              <td width="11%" height="40" align="center">缴费比例</td>
              <td width="11%" height="40" align="center">金额</td>
              <td width="11%" height="40" align="center">基数</td>
              <td width="11%" height="40" align="center">缴费比例</td>
              <td width="11%" height="40" align="center">金额</td>
              <td width="11%" height="40" align="center">小计</td>
            </tr>
            <tr>
              <td align="center">养老保险</td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grYlBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grYlProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.grYlMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyYlBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyYlProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.companyYlMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.ylInsuranceMoney" placeholder="00.00"/>
              </td>
            </tr>
            <tr>
              <td align="center">工商保险</td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grGsBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grGsProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.grGsMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyGsBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyGsProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.companyGsMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.gsInsuranceMoney" placeholder="00.00"/>
              </td>
            </tr>
            <tr>
              <td align="center">失业保险</td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grSyBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grSyProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.grSyMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companySyBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companySyProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.companySyMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.syInsuranceMoney" placeholder="00.00"/>
              </td>
            </tr>
            <tr>
              <td align="center">生育保险</td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grBirthBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grBirthProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.grBirthMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyBirthBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyBirthProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.companyBirthMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.birthInsuranceMoney" placeholder="00.00"/>
              </td>
            </tr>
            <tr>
              <td align="center">医疗保险</td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grCareBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.grCareProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.grCareMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyCareBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" v-model="form.companyCareProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.companyCareMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input type="number" onfocus="{value =''}" :disabled="true" v-model="form.careInsuranceMoney" placeholder="00.00"/>
              </td>
            </tr>
            <tr>
              <td></td>
              <td align="center" colspan="3">个人缴纳：<input :disabled="true" v-model="form.grInsuranceMoney"
                                                         placeholder="00.00"/></td>
              <td align="center" colspan="3">公司缴纳：<input :disabled="true" v-model="form.companyInsuranceMoney"
                                                         placeholder="00.00"/></td>
              <td>合计：<input :disabled="true" v-model="form.insuranceMoney" placeholder="00.00"/></td>
            </tr>
          </table>
          <h1>公积金</h1>
          <el-checkbox v-model="checked" @change="nojj">不缴纳公积金</el-checkbox>
          <el-divider></el-divider>
          <table border="1" cellspacing="1" cellpadding="0" bordercolor="#87cefa">
            <tr bgcolor="#87cefa">
              <td colspan="4" height="40" align="center">个人缴纳</td>
              <td colspan="4" height="40" align="center">企业缴纳</td>
            </tr>
            <tr bgcolor="#87cefa">
              <td height="40" width="11%" align="center">缴费项目</td>
              <td height="40" width="11%" align="center">基数</td>
              <td height="40" width="11%" align="center">缴费比例</td>
              <td height="40" width="11%" align="center">金额</td>
              <td height="40" width="11%" align="center">基数</td>
              <td height="40" width="11%" align="center">缴费比例</td>
              <td height="40" width="11%" align="center">金额</td>
              <td height="40" width="11%" align="center">小计</td>
            </tr>
            <tr>
              <td align="center">公积金</td>
              <td>
                <el-input :disabled="isjn" onfocus="{value =''}" v-model="form.grFundBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input :disabled="isjn" onfocus="{value =''}" v-model="form.grFundProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input :disabled="true" onfocus="{value =''}" v-model="form.grFundMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input :disabled="isjn" onfocus="{value =''}" v-model="form.companyFundBase" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input :disabled="isjn" onfocus="{value =''}" v-model="form.companyFundProportion" @blur="blurs()" placeholder="00.00"/>
              </td>
              <td>
                <el-input :disabled="true" onfocus="{value =''}" v-model="form.companyFundMoney" placeholder="00.00"/>
              </td>
              <td>
                <el-input :disabled="true" onfocus="{value =''}" v-model="form.fundSubtotal" placeholder="00.00"/>
              </td>
            </tr>

            <tr>
              <td></td>
              <td align="center" colspan="3">个人缴纳：<input :disabled="true" v-model="form.grFundPayment"
                                                         placeholder="00.00"/></td>
              <td align="center" colspan="3">公司缴纳：<input :disabled="true" v-model="form.companyFundPayment"
                                                         placeholder="00.00"/></td>
              <td>合计：<input :disabled="true" v-model="form.fundTotal" placeholder="00.00"/></td>
            </tr>
          </table>



      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {listScheme, getScheme, delScheme, addScheme, updateScheme} from "@/api/system/scheme";
import {CodeToText, regionData, TextToCode} from 'element-china-area-data'


export default {
  name: "Scheme",
  data() {
    return {
      checked: false,
      isjn: false,
      //省市区
      optionss: regionData,
      selectedAddressOptions: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      schemeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        schemeName: null,
        schemePlatform: null,
        schemeCity: null,
        grYlBase: null,
        grGsBase: null,
        grSyBase: null,
        grBirthBase: null,
        grCareBase: null,
        grYlProportion: null,
        grGsProportion: null,
        grSyProportion: null,
        grBirthProportion: null,
        grCareProportion: null,
        grYlMoney: null,
        grGsMoney: null,
        grSyMoney: null,
        grBirthMoney: null,
        grCareMoney: null,
        companyYlBase: null,
        companyGsBase: null,
        companySyBase: null,
        companyBirthBase: null,
        companyCareBase: null,
        companyYlProportion: null,
        companyGsProportion: null,
        companySyProportion: null,
        companyBirthProportion: null,
        companyCareProportion: null,
        companyYlMoney: null,
        companyGsMoney: null,
        companySyMoney: null,
        companyBirthMoney: null,
        companyCareMoney: null,
        grInsuranceMoney: null,
        companyInsuranceMoney: null,
        insuranceMoney: null,
        ylInsuranceMoney: null,
        gsInsuranceMoney: null,
        syInsuranceMoney: null,
        birthInsuranceMoney: null,
        careInsuranceMoney: null,
        grFundBase: null,
        grFundProportion: null,
        grFundMoney: null,
        companyFundBase: null,
        companyFundProportion: null,
        companyFundMoney: null,
        fundSubtotal: null,
        fundTotal: null,
        grFundPayment: null,
        companyFundPayment: null,
        isFund: null,
        isDelete: null
      },
      // 表单参数
      form: {
        grYlBase: 0,
        grGsBase: 0,
        grSyBase: 0,
        grBirthBase: 0,
        grCareBase: 0,
        grYlProportion: 0,
        grGsProportion: 0,
        grSyProportion: 0,
        grBirthProportion: 0,
        grCareProportion: 0,
        grYlMoney: 0,
        grGsMoney: 0,
        grSyMoney: 0,
        grBirthMoney: 0,
        grCareMoney: 0,
        companyYlBase: 0,
        companyGsBase: 0,
        companySyBase: 0,
        companyBirthBase: 0,
        companyCareBase: 0,
        companyYlProportion: 0,
        companyGsProportion: 0,
        companySyProportion: 0,
        companyBirthProportion: 0,
        companyCareProportion: 0,
        companyYlMoney: 0,
        companyGsMoney: 0,
        companySyMoney: 0,
        companyBirthMoney: 0,
        companyCareMoney: 0,
        grInsuranceMoney: 0,
        companyInsuranceMoney: 0,
        insuranceMoney: 0,
        ylInsuranceMoney: 0,
        gsInsuranceMoney: 0,
        syInsuranceMoney: 0,
        birthInsuranceMoney: 0,
        careInsuranceMoney: 0,
        grFundBase: 0,
        grFundProportion: 0,
        grFundMoney: 0,
        companyFundBase: 0,
        companyFundProportion: 0,
        companyFundMoney: 0,
        fundSubtotal: 0,
        fundTotal: 0,
        grFundPayment: 0,
        companyFundPayment: 0,
      },
      // 表单校验
      rules: {
        schemeName: [
          {required: true, message: '方案名称不能为空', trigger: 'blur'}
        ],
        schemeCity: [
          {required: true, message: '参保城市不能为空', trigger: 'blur'}
        ],
      }
    };
  },
  created() {


    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {

      this.loading = true;
      listScheme(this.queryParams).then(response => {
        this.schemeList = response.rows;
        this.total = response.total;
      });
      this.loading = false;
    },



    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        sid: null,
        schemeName: null,
        schemePlatform: null,
        schemeCity: null,
        grYlBase: null,
        grGsBase: null,
        grSyBase: null,
        grBirthBase: null,
        grCareBase: null,
        grYlProportion: null,
        grGsProportion: null,
        grSyProportion: null,
        grBirthProportion: null,
        grCareProportion: null,
        grYlMoney: null,
        grGsMoney: null,
        grSyMoney: null,
        grBirthMoney: null,
        grCareMoney: null,
        companyYlBase: null,
        companyGsBase: null,
        companySyBase: null,
        companyBirthBase: null,
        companyCareBase: null,
        companyYlProportion: null,
        companyGsProportion: null,
        companySyProportion: null,
        companyBirthProportion: null,
        companyCareProportion: null,
        companyYlMoney: null,
        companyGsMoney: null,
        companySyMoney: null,
        companyBirthMoney: null,
        companyCareMoney: null,
        grInsuranceMoney: null,
        companyInsuranceMoney: null,
        insuranceMoney: null,
        ylInsuranceMoney: null,
        gsInsuranceMoney: null,
        syInsuranceMoney: null,
        birthInsuranceMoney: null,
        careInsuranceMoney: null,
        grFundBase: null,
        grFundProportion: null,
        grFundMoney: null,
        companyFundBase: null,
        companyFundProportion: null,
        companyFundMoney: null,
        fundSubtotal: null,
        fundTotal: null,
        grFundPayment: null,
        companyFundPayment: null,
        isFund: null,
        isDelete: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.sid)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {

      this.form = {
        grYlBase: 0,
        grGsBase: 0,
        grSyBase: 0,
        grBirthBase: 0,
        grCareBase: 0,
        grYlProportion: 0,
        grGsProportion: 0,
        grSyProportion: 0,
        grBirthProportion: 0,
        grCareProportion: 0,
        grYlMoney: 0,
        grGsMoney: 0,
        grSyMoney: 0,
        grBirthMoney: 0,
        grCareMoney: 0,
        companyYlBase: 0,
        companyGsBase: 0,
        companySyBase: 0,
        companyBirthBase: 0,
        companyCareBase: 0,
        companyYlProportion: 0,
        companyGsProportion: 0,
        companySyProportion: 0,
        companyBirthProportion: 0,
        companyCareProportion: 0,
        companyYlMoney: 0,
        companyGsMoney: 0,
        companySyMoney: 0,
        companyBirthMoney: 0,
        companyCareMoney: 0,
        grInsuranceMoney: 0,
        companyInsuranceMoney: 0,
        insuranceMoney: 0,
        ylInsuranceMoney: 0,
        gsInsuranceMoney: 0,
        syInsuranceMoney: 0,
        birthInsuranceMoney: 0,
        careInsuranceMoney: 0,
        grFundBase: 0,
        grFundProportion: 0,
        grFundMoney: 0,
        companyFundBase: 0,
        companyFundProportion: 0,
        companyFundMoney: 0,
        fundSubtotal: 0,
        fundTotal: 0,
        grFundPayment: 0,
        companyFundPayment: 0,
      };
      this.selectedAddressOptions = null;

      this.open = true;
      this.title = "新增参保方案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const sid = row.sid || this.ids
      getScheme(sid).then(response => {

        this.form = response.data;
        var addressStr = new Array(); //定义一数组
        addressStr = (this.form.schemeCity).split("/"); //字符分割
        this.selectedAddressOptions = TextToCode[addressStr[0]][addressStr[1]][addressStr[2]].code;

        this.open = true;
        this.title = "修改";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.sid != null) {
            updateScheme(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;

              this.getList();
            });
          } else {
            addScheme(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const sids = row.sid || this.ids;
      this.$modal.confirm('是否确认删除编号为"' + sids + '"的数据项？').then(function () {
        return delScheme(sids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/scheme/export', {
        ...this.queryParams
      }, `scheme_${new Date().getTime()}.xlsx`)
    },
    //省市区
    handleChange(value) {
      //我们选择地址后，selectedAddressOptions 会保存对应的区域码，
      //例如北京的区域码为'110000'
      //我们要取出区域码对应的汉字，就需要用CodeToText(区域码)进行输出
      var schemeCity = ''
      this.selectedAddressOptions.map(item => schemeCity += CodeToText[item] + '/')
      this.form.schemeCity = schemeCity;//更新表单的数据，以便保存更新
    },

    nojj() {
      if (this.checked) {
        this.form.grFundBase = 0;
        this.form.grFundProportion = 0;
        this.form.grFundMoney = 0;
        this.form.companyFundBase = 0;
        this.form.companyFundProportion = 0;
        this.form.companyFundMoney = 0;
        this.form.fundSubtota = 0;
        this.form.grFundPayment = 0;
        this.form.companyFundPayment = 0;
        this.form.fundTotal = 0;
        this.isjn = true;
      } else {
        this.isjn = false;
      }
    },
    blurs() {
      //养老个人金额

      this.form.grYlMoney = this.mul(this.form.grYlBase, this.form.grYlProportion).toFixed(2)
      //养老企业金额

      this.form.companyYlMoney = this.mul(this.form.companyYlBase, this.form.companyYlProportion).toFixed(2)
      //养老小计

      this.form.ylInsuranceMoney = this.sum(this.form.grYlMoney, this.form.companyYlMoney).toFixed(2)

      //工商个人金额
      this.form.grGsMoney = this.mul(this.form.grGsBase, this.form.grGsProportion).toFixed(2)
      //工商企业金额
      this.form.companyGsMoney = this.mul(this.form.companyGsBase, this.form.companyGsProportion).toFixed(2)
      //工商小计

      this.form.gsInsuranceMoney = this.sum(this.form.grGsMoney, this.form.companyGsMoney).toFixed(2)

      //失业个人金额

      this.form.grSyMoney = this.mul(this.form.grSyBase, this.form.grSyProportion).toFixed(2)
      //失业企业金额

      this.form.companySyMoney = this.mul(this.form.companySyBase, this.form.companySyProportion).toFixed(2)

      //失业小计

      this.form.syInsuranceMoney = this.sum(this.form.grSyMoney, this.form.companySyMoney).toFixed(2)

      //生育个人金额

      this.form.grBirthMoney = this.mul(this.form.grBirthBase, this.form.grBirthProportion).toFixed(2)
      //生育企业金额

      this.form.companyBirthMoney = this.mul(this.form.companyBirthBase, this.form.companyBirthProportion).toFixed(2)
      //生育小计

      this.form.birthInsuranceMoney = this.sum(this.form.grBirthMoney, this.form.companyBirthMoney).toFixed(2)

      //医疗个人金额

      this.form.grCareMoney = this.mul(this.form.grCareBase, this.form.grCareProportion).toFixed(2)
      //医疗企业金额

      this.form.companyCareMoney = this.mul(this.form.companyCareBase, this.form.companyCareProportion).toFixed(2)
      //医疗小计
      /*this.form.careInsuranceMoney = (Number(this.form.grCareMoney + this.form.companyCareMoney).toFixed(2))*/
      this.form.careInsuranceMoney = this.sum(this.form.grCareMoney, this.form.companyCareMoney).toFixed(2)

      //社保个人缴纳
      /*this.form.grInsuranceMoney = (Number(this.form.grYlMoney + this.form.grGsMoney + this.form.grSyMoney + this.form.grBirthMoney + this.form.grCareMoney).toFixed(2))*/
      this.form.grInsuranceMoney = this.sum(this.sum(this.sum(this.form.grYlMoney, this.form.grGsMoney), this.sum(this.form.grSyMoney, this.form.grBirthMoney)), this.form.grCareMoney).toFixed(2)

      //社保公司缴纳
      /*this.form.companyInsuranceMoney = (Number(this.form.companyYlMoney + this.form.companyGsMoney + this.form.companySyMoney + this.form.companyBirthMoney + this.form.companyCareMoney).toFixed(2))*/
      this.form.companyInsuranceMoney = this.sum(this.sum(this.sum(this.form.companyYlMoney, this.form.companyGsMoney), this.sum(this.form.companySyMoney, this.form.companyBirthMoney)), this.form.companyCareMoney).toFixed(2)

      //社保合计
      /*this.form.insuranceMoney = (Number(this.form.grInsuranceMoney + this.form.companyInsuranceMoney).toFixed(2))*/
      this.form.insuranceMoney = this.sum(this.form.grInsuranceMoney, this.form.companyInsuranceMoney).toFixed(2)

      //公积金个人金额
      /*this.form.grFundMoney = (Number(this.form.grFundBase * this.form.grFundProportion).toFixed(2))*/
      this.form.grFundMoney = this.mul(this.form.grFundBase, this.form.grFundProportion).toFixed(2)

      //公积金公司金额
      /*this.form.companyFundMoney = (Number(this.form.companyFundBase * this.form.companyFundProportion).toFixed(2))*/
      this.form.companyFundMoney = this.mul(this.form.companyFundBase, this.form.companyFundProportion).toFixed(2)

      //公积金小计
      /*this.form.fundSubtotal = (Number(this.form.grFundMoney + this.form.companyFundMoney).toFixed(2))*/
      this.form.fundSubtotal = this.sum(this.form.grFundMoney, this.form.companyFundMoney).toFixed(2)

      //公积金个人缴纳
      this.form.grFundPayment = this.form.grFundMoney

      //公积金公司缴纳
      this.form.companyFundPayment = this.form.companyFundMoney

      //公积金合计
      /*this.form.fundTotal = (Number(this.form.grFundPayment + this.form.companyFundPayment).toFixed(2))*/
      this.form.fundTotal = this.sum(this.form.grFundPayment, this.form.companyFundPayment).toFixed(2)

    },

    sum(arg1, arg2) {
      let r1, r2
      try {
        r1 = arg1.toString().split('.')[1].length
      } catch (e) {
        r1 = 0
      }
      try {
        r2 = arg2.toString().split('.')[1].length
      } catch (e) {
        r2 = 0
      }
      const c = Math.abs(r1 - r2)
      const m = Math.pow(10, Math.max(r1, r2))
      if (c > 0) {
        const cm = Math.pow(10, c)
        if (r1 > r2) {
          arg1 = Number(arg1.toString().replace('.', ''))
          arg2 = Number(arg2.toString().replace('.', '')) * cm
        } else {
          arg1 = Number(arg1.toString().replace('.', '')) * cm
          arg2 = Number(arg2.toString().replace('.', ''))
        }
      } else {
        arg1 = Number(arg1.toString().replace('.', ''))
        arg2 = Number(arg2.toString().replace('.', ''))
      }
      return (arg1 + arg2) / m
    },
    /**
     ** 减法函数，用来得到精确的减法结果
     ** 说明：javascript 的减法结果会有误差，在两个浮点 g2)会比较明显。这个函数返回较为精确的减法结果。
     ** 调用：sub(arg1,arg2)
     ** 返回值：arg1 加上 arg2 的精确结果
     **/
    sub(arg1, arg2) {
      let r1, r2
      try {
        r1 = arg1.toString().split('.')[1].length
      } catch (e) {
        r1 = 0
      }
      try {
        r2 = arg2.toString().split('.')[1].length
      } catch (e) {
        r2 = 0
      }
      const c = Math.abs(r1 - r2)
      const m = Math.pow(10, Math.max(r1, r2))
      if (c > 0) {
        const cm = Math.pow(10, c)
        if (r1 > r2) {
          arg1 = Number(arg1.toString().replace('.', ''))
          arg2 = Number(arg2.toString().replace('.', '')) * cm
        } else {
          arg1 = Number(arg1.toString().replace('.', '')) * cm
          arg2 = Number(arg2.toString().replace('.', ''))
        }
      } else {
        arg1 = Number(arg1.toString().replace('.', ''))
        arg2 = Number(arg2.toString().replace('.', ''))
      }
      return (arg1 - arg2) / m
    },
    /**
     ** 乘法函数，用来得到精确的乘法结果
     ** 说明：javascript 的乘法结果会有误差，在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
     ** 调用：mul(arg1,arg2)
     ** 返回值：arg1 乘以 arg2 的精确结果
     **/
    mul(arg1, arg2) {
      let m = 0
      const s1 = arg1.toString()
      const s2 = arg2.toString()
      try {
        m += s1.split('.')[1].length
      } catch (e) {

      }
      try {
        m += s2.split('.')[1].length
      } catch (e) {
      }
      return ((Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) /
        Math.pow(10, m)
      )
    },
    /**
     ** 除法函数，用来得到精确的除法结果
     ** 说明：javascript 的除法结果会有误差，在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
     ** 调用：div(arg1,arg2)
     ** 返回值：arg1 除以 arg2 的精确结果
     **/
    div(arg1, arg2) {
      let t1 = 0,
        t2 = 0
      try {
        t1 = arg1.toString().split('.')[1].length
      } catch (e) {
      }
      try {
        t2 = arg2.toString().split('.')[1].length
      } catch (e) {
      }
      const r1 = Number(arg1.toString().replace('.', ''))
      const r2 = Number(arg2.toString().replace('.', ''))
      return (r1 / r2) * Math.pow(10, t2 - t1)
    },
  }
};
</script>
